package com.example.plane.peng;

import android.graphics.Bitmap;

import java.util.ArrayList;

public class peng {//本次碰撞为矩形碰撞
    public Bitmap bitmap1,bitmap2;
    public  int b1x,b1y,b2x,b2y;
    public  int w1,w2,h1,h2;
    public ArrayList<int[]> bitmaparry1=new ArrayList<int[]>();
    public ArrayList<int[]> bitmaparry2=new ArrayList<int[]>();
    public int[] position=new int[2];
//   public ArrayList<Integer> x =new ArrayList<>();
//   public  ArrayList<Integer> y =new ArrayList<>();
    public  peng(){}
   public void  penginit(Bitmap bitmap1,int b1x,int b1y,Bitmap bitmap2,int b2x,int b2y) {//坐标应该是起始位置
        this.bitmap1=bitmap1;
        this.bitmap2=bitmap2;
        this.b1x=b1x;
        this.b1y=b1y;
       this.b2x=b2x;
       this.b2y=b2y;
       w1=bitmap1.getWidth();
       h1=bitmap1.getHeight();
       w2=bitmap2.getWidth();
       h2=bitmap2.getHeight();
//       setBitmaparry();
    }
    public boolean Jpeng() {

        if (b1x >= b2x && b1x >= b2x + w2) {
            return false;
        } else if (b1x <= b2x && b1x + w1 <= b2x) {
            return false;
        } else if (b1y >= b2y && b1y >=b2y + h2) {
            return false;
        } else if (b1y <= b2y && b1y + h1 <= b2y) {
            return false;
        }
        return true;
    }


    public boolean JpengT(){
       if(b2x+bitmap2.getWidth()<b1x||b2x>b1x+bitmap1.getWidth()){
           if(b2y+bitmap2.getHeight()<b1y||b2y>b1y+bitmap1.getHeight()){
                return  false;
           }

       }

       return true;

    }
    public void setBitmaparry(){
       for(int i=0;i<(bitmap1.getWidth()*bitmap1.getHeight());i++) {
            position[0]=b1x;
            position[1]=b1y;
            b1x+=1;
            b1y+=1;
            bitmaparry1.add(position);
        }
        for(int i=0;i<(bitmap2.getWidth()*bitmap2.getHeight());i++) {
            position[0]=b1x;
            position[1]=b1y;
            b2x+=1;
            b2y+=1;
            bitmaparry2.add(position);
        }
    }
}
